package org.dromara.admin.tenant.controller;

import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.dromara.admin.domain.bo.OrderBo;
import org.dromara.admin.domain.vo.OrderVo;
import org.dromara.admin.service.IOrderService;
import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.web.core.BaseController;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 用户订单控制器
 *
 * @author Lion Li
 * @date 2025-09-03
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/tenant/order")
public class TenantOrderController extends BaseController {

    private final IOrderService orderService;

    /**
     * 查询我的订单列表
     */
    @GetMapping("myList")
    public TableDataInfo<OrderVo> myList(OrderBo bo, PageQuery pageQuery) {
        bo.setUserId(LoginHelper.getUserId());
        return orderService.queryMyPageList(bo, pageQuery);
    }

    /**
     * 获取订单详细信息
     *
     * @param id 主键
     */
    @GetMapping("/{id}")
    public R<OrderVo> tenantGetOrderInfo(@NotNull(message = "主键不能为空")
                                     @PathVariable Long id) {
        return R.ok(orderService.tenantGetOrderInfo(id));
    }

}
